PER.exhibit
Class Sequencer

java.lang.Object
  extended byPER.exhibit.Sequencer

public class Sequencer
extends java.lang.Object

Controls the sequence of actions in a rover mission.


Field Summary
static int ERROR
          mission ended due to rover error
static int INCOMPLETE
          mission terminated early: tried to leave the exhibit
static int INTERRUPTED
          mission terminated early: ran into something early (also for e-stop)
static int NO_MISSION
          no missions have been run; sequencer is waiting for a new mission
static int NO_ROCK
          mission terminated early: no rock was found
static int POSSIBLE_ERROR
          mission ended due to a possible error.
static int RUNNING
          mission is still running
static int SUCCESS
          mission completed successfully
 
Constructor Summary
Sequencer(Rover rov)
          Creates a new instance of Sequencer
 
Method Summary
 Action getCurrentAction()
          Returns the Action that is currently being executed, or null if no such Action exists.
 int getLastMissionAngleToRock()
          Returns the angle (in degrees) that the rover had to turn to find the rock, after turning and driving as told.
 int getLastMissionDist()
          Return the distance (in centimeters) that the rover traveled in the last mission.
 int getLastMissionDistToRock()
          Return the distance (in centimeters) that the rover traveled beyond the original distance it was told.
 java.awt.image.BufferedImage getLastMissionImage()
          Returns the image taken by AnalyzeRock or, if that image is null, the last image taken.
 java.awt.image.BufferedImage getLastMissionNoUVImage()
          Returns the image taken by AnalyzeRock or, if that image is null, the last image taken.
 int getLastMissionTime()
          Return the time (in milliseconds) that the last mission took to complete.
 int getStatus()
          Return the current status of the sequencer (for exmaple: RUNNING).
 boolean runMission(int turnDegrees, int driveCm)
          Begin execution of a mission.
 boolean runMission(int turnDegrees, int driveCm, boolean findRock)
          Begin execution of a mission.
 void setMissionProgressPanel(MissionProgressPanel panel)
          Set the MissionProgressPanel that the sequencer should use as a visual display of the current mission's status.
 void setStatus(int s)
          hack for displaying error message when error in panorama
 void stop()
          Immediately stop the current mission.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MISSION

public static final int NO_MISSION
no missions have been run; sequencer is waiting for a new mission

See Also:
Constant Field Values

RUNNING

public static final int RUNNING
mission is still running

See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
mission completed successfully

See Also:
Constant Field Values

NO_ROCK

public static final int NO_ROCK
mission terminated early: no rock was found

See Also:
Constant Field Values

INCOMPLETE

public static final int INCOMPLETE
mission terminated early: tried to leave the exhibit

See Also:
Constant Field Values

INTERRUPTED

public static final int INTERRUPTED
mission terminated early: ran into something early (also for e-stop)

See Also:
Constant Field Values

ERROR

public static final int ERROR
mission ended due to rover error

See Also:
Constant Field Values

POSSIBLE_ERROR

public static final int POSSIBLE_ERROR
mission ended due to a possible error. More checks are required to determine if this is a real error. For example when a driveToAction is interrupted within the buffer distance, it is not really an error. If this is the sequencer status, the mission should not be considered complete.

See Also:
Constant Field Values
Constructor Detail

Sequencer

public Sequencer(Rover rov)
Creates a new instance of Sequencer

Method Detail

runMission

public boolean runMission(int turnDegrees,
                          int driveCm)
Begin execution of a mission. Missions are always of the form:
  1. turn the given number of degrees
  2. drive the given number of centimeters
  3. search for a nearby rock
  4. if a rock is found, drive toward it and 'analyze' it

Parameters:
turnDegrees - the number of degrees to turn (greater than 0 is left)
driveCm - the number of centimeters to drive
Returns:
a boolean indicating whether the mission began (false implies that something else is already running; call stop first)

runMission

public boolean runMission(int turnDegrees,
                          int driveCm,
                          boolean findRock)
Begin execution of a mission. Missions are always of the form:
  1. turn the given number of degrees
  2. drive the given number of centimeters
  3. if findRock, search for a nearby rock
  4. if a rock is found, drive toward it and 'analyze' it

Parameters:
turnDegrees - the number of degrees to turn (greater than 0 is left)
driveCm - the number of centimeters to drive
findRock - indicates whether or not to search for a rock at the end of the mission
Returns:
a boolean indicating whether the mission began (false implies that something else is already running; call stop first)

getStatus

public int getStatus()
Return the current status of the sequencer (for exmaple: RUNNING).


setStatus

public void setStatus(int s)
hack for displaying error message when error in panorama


stop

public void stop()
Immediately stop the current mission.


getCurrentAction

public Action getCurrentAction()
Returns the Action that is currently being executed, or null if no such Action exists. Returns the last Action to begin execution, if the Mission failed.


setMissionProgressPanel

public void setMissionProgressPanel(MissionProgressPanel panel)
Set the MissionProgressPanel that the sequencer should use as a visual display of the current mission's status.


getLastMissionTime

public int getLastMissionTime()
Return the time (in milliseconds) that the last mission took to complete.


getLastMissionDist

public int getLastMissionDist()
Return the distance (in centimeters) that the rover traveled in the last mission. This includes any distance to get to a rock, beyond the distance the rover was told to travel.


getLastMissionDistToRock

public int getLastMissionDistToRock()
Return the distance (in centimeters) that the rover traveled beyond the original distance it was told. Returns the absolute value of the distance so that the number is always positive even if the rover stopped short.


getLastMissionAngleToRock

public int getLastMissionAngleToRock()
Returns the angle (in degrees) that the rover had to turn to find the rock, after turning and driving as told.


getLastMissionImage

public java.awt.image.BufferedImage getLastMissionImage()
Returns the image taken by AnalyzeRock or, if that image is null, the last image taken.


getLastMissionNoUVImage

public java.awt.image.BufferedImage getLastMissionNoUVImage()
Returns the image taken by AnalyzeRock or, if that image is null, the last image taken.